package admin.shell.commands;

import game.Player;

import java.util.List;

import admin.ui.ProxyMediator;

public class ListUsersCommand extends ShellCommand {

	@Override
	public void execute(ProxyMediator proxy, String[] parameters) {
		boolean showAll = parameters.length > 1 && parameters[1].equals("all");
			
		List<Player> players = proxy.listPlayers(showAll);
		
		if (players.size() == 0) {
			System.out.println("No players found");
			return;
		}
		
		System.out.printf("%-20s %-8s %-8s %s\n", "Login", "Ranking", "Online?", "Role");
		
		for (Player player : players) {			
			System.out.printf("%-20s %-8d %-8s %s\n", player.getLogin(), player.getRanking(), (player.isOnline() ? "yes" : "no"), player.getRole());
		}
		
		System.out.println("\nTotal: " + players.size());
	}

}
